<?php
class Table_User extends CF_Db_Table_Abstract
{
	protected $_name = '##_users';
	
	public function getList($roleId, $start, $limit)
	{
		$store = $this->select(
			'id,email,first_name,last_name,active', 
			new CF_Db_Expr('`role_id`=%s', $roleId),
			null,
			$limit,
			$start
		);
		return array(
			'total' => $store->getFoundRows(),
			'rows'	=> $store->getAll()
		);
	}
	
	public function search($field, $value, $start, $limit)
	{
		$store = $this->select(
			'id,email,first_name,last_name,active',
			new CF_Db_Expr("`$field` LIKE %s", "%$value%"),
			null,
			$limit,
			$start
		);
		
		return array(
			'total' => $store->getFoundRows(),
			'rows'	=> $store->getAll()
		);
	}
}